import { createAPI } from '@/api/http';
import { Opts } from '@/api/opts';

/**
 *  @description 添加用户
 *  @name createUser
 *  @param  name 用户名 {string} 必传参数
 *  @param  userName 账号 {string} 必传参数
 *  @param  password 密码 {string} 必传参数
 *  @param  age 年龄 {integer} 
 *  @param  sex 性别 {boolean} 
 *  @param  phone 手机号 {string} 
 *  @param  email 邮箱 {string} 
 *  @param  avatar 头像 {string} 
 *  @param  memo 备注 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const createUser = (opts: Opts) =>
  createAPI({
    method: 'post',
    url: '/wit/user/createUser',
    opts,
  });

/**
 *  @description 删除用户
 *  @name deleteUser
 *  @param  id user id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const deleteUser = (opts: Opts) =>
  createAPI({
    method: 'delete',
    url: '/wit/user/deleteUser',
    opts,
  });

/**
 *  @description 通过id获取用户信息
 *  @name getUserById
 *  @param  id user id {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getUserById = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/user/getUserById',
    opts,
  });

/**
 *  @description 获取用户信息
 *  @name getUserInfo

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getUserInfo = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/user/getUserInfo',
    opts,
  });

/**
 *  @description 获取用户信息
 *  @name getUserList
 *  @param  pageNum 页码 {integer} 
 *  @param  pageSize 每页数 {integer} 
 *  @param  userName 用户名 {string} 
 *  @param  name 昵称 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const getUserList = (opts: Opts) =>
  createAPI({
    method: 'get',
    url: '/wit/user/getUserList',
    opts,
  });

/**
 *  @description 用户登录
 *  @name login
 *  @param  userName 账号 {string} 必传参数
 *  @param  password 密码 {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const login = (opts: Opts) =>
  createAPI({
    method: 'post',
    url: '/wit/user/login',
    opts,
  });

/**
 *  @description 修改密码
 *  @name updatePassword
 *  @param  password 原密码 {string} 必传参数
 *  @param  newPassword 新密码 {string} 必传参数
 *  @param  towPassword 确认密码 {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const updatePassword = (opts: Opts) =>
  createAPI({
    method: 'put',
    url: '/wit/user/updatePassword',
    opts,
  });

/**
 *  @description 修改用户
 *  @name updateUser
 *  @param  id ID {string} 必传参数
 *  @param  name 用户名 {string} 
 *  @param  age 年龄 {integer} 
 *  @param  sex 性别 {boolean} 
 *  @param  phone 手机号 {string} 
 *  @param  email 邮箱 {string} 
 *  @param  avatar 头像 {string} 
 *  @param  memo 备注 {string} 

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const updateUser = (opts: Opts) =>
  createAPI({
    method: 'put',
    url: '/wit/user/updateUser',
    opts,
  });

/**
 *  @description 修改用户密码
 *  @name updateUserPassword
 *  @param  id ID {string} 必传参数
 *  @param  password 新密码 {string} 必传参数
 *  @param  towPassword 确认密码 {string} 必传参数

 *  @example 示例1
 *   onMounted(async () => {
 *     const { data } = await createUser({ data: { id: '1' } });
 *   });
 *  @example 示例2
 *  createUser({ data: { id: '1' } }).then(res => {});
 *  @example 示例3
 *  const { data } = await deleteUser({ params: { id: '1' } })
 */
export const updateUserPassword = (opts: Opts) =>
  createAPI({
    method: 'put',
    url: '/wit/user/updateUserPassword',
    opts,
  });
